package com.mathlearning.auth.repository;

import com.mathlearning.auth.entity.DiscussionLike;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface DiscussionLikeRepository extends JpaRepository<DiscussionLike, Long> {
    
    // 查找用户对某个讨论的点赞记录
    Optional<DiscussionLike> findByDiscussionIdAndUserId(Long discussionId, Long userId);
    
    // 判断用户是否点赞了某个讨论
    boolean existsByDiscussionIdAndUserId(Long discussionId, Long userId);
    
    // 获取用户点赞的所有讨论ID
    List<DiscussionLike> findByUserId(Long userId);
    
    // 删除用户对某个讨论的点赞
    void deleteByDiscussionIdAndUserId(Long discussionId, Long userId);
}








